#pragma once

#include <iostream>
#include <string>
#include "Protocol.hpp"

using namespace protrol;
using namespace std;

class Calculate
{
public:
    Calculate()
    {
    }
    Response Excute(const Request &req)
    {
        Response resp(0, 0);
        switch (req._oper)
        {
        case '+':
            resp._res = req._x + req._y;
            break;
        case '-':
            resp._res = req._x - req._y;
            break;
        case '*':
            resp._res = req._x * req._y;
            break;
        case '/':
            if (req._y != 0)
                resp._res = req._x / req._y;
            else
                resp._code = 1;
            break;
        case '%':
            if (req._y != 0)
                resp._res = req._x / req._y;
            else
                resp._code = 2;
        case '^':
            resp._res = req._x ^ req._y;
            break;
        case '&':
            resp._res = req._x & req._y;
            break;
        case '|':
            resp._res = req._x | req._y;
            break;
        default:
            resp._code = 3;
            break;
        }
        return resp;
    }
    

private:
};